module RbExt
  module Integer
    
    # Returns an array with this Fixnum calculated as minutes (the first element)
    # and seconds (the second element)
    #
    # Example:
    #   3601.to_minutes_and_seconds   # => [60, 1] meaning: 3601 seconds are 60 minutes and 1 second
    #
    def to_minutes_and_seconds
      [self / 60, self % 60]
    end
    
    # Calculates the cross sum of this integer
    #
    # Example:
    #   123.cross_sum   # => 6
    #
    def cross_sum
      _self = self; sum = 0
      
      while _self > 0
        sum += _self % 10
        _self /= 10
      end
      
      return sum
    end
    
    # Calculates the cross product of this integer
    #
    # Example:
    #   12345.cross_product   # => 120
    #
    def cross_product
      _self = self; product = 1
      
      while _self > 0
        product *= _self % 10
        _self /= 10
      end
      
      return product
    end
  end
end